#include <stdio.h>

int main()
{
#if 1
    /* for循环 */
    int count = 3;
    for (size_t i = 0; i < count; i++) //(初始化语句；判断语句；基本语句)
    {
        printf("hello world!\n");
    }
#endif

#if 0
    /* while循环 */
    /* 千万不要死循环*/
    int cnt = 5;
    while (cnt)
    {
        printf("welcome to 271Class\n");
        cnt -= 1;
    }
#endif

#if 0
    /* do………while */
    int flag = 0;
    do
    {
        printf("77\n");
    } while (flag);  //先做再判断
#endif

#if 0
    int num1, num2;
    int cnt = 0;
    for (int num = 12; num < 100; num++)
    {
        int a = num / 10;
        int b = num - a * 10;
        //printf("a = %d, b = %d", a, b);
        num1 = a * 10 + b;
        num2 = b * 10 + a;
        if (num1 == num2)
        {
            printf("num = %d\n", num);
            cnt++;
        }
    }
    for (int num = 100; num < 1000; num++)
    {
        int a = num / 100;
        int b = num / 10 - a * 10;
        int c = num - a * 100 - b * 10;
        //printf("a = %d, b = %d, c = %d", a, b, c);
        num1 = a * 100 + b * 10 + c;
        num2 = c * 100 + b * 10 + a;
        if (num1 == num2)
        {
            printf("num = %d\n", num);
            cnt++;
        }
    }
    for (int num = 1000; num < 10000; num++)
    {
        int a = num / 1000;
        int b = num / 100 - a * 10;
        int c = num / 10 - a * 100 - b * 10;
        int d = num - a * 1000 - b * 100 - c * 10;
        // printf("a = %d, b = %d, c = %d, d = %d", a, b, c, d);
        num1 = a * 1000 + b * 100 + c * 10 + d;
        num2 = d * 1000 + c * 100 + b * 10 + a;
        if (num1 == num2)
        {
            printf("num = %d\n", num);
            cnt++;
        }
    }
    printf("cnt = %d", cnt);
#endif

    return 0;
}